package com.example.prueba2;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;

public class logica {
	
	String NAMESPACE;
	String URL;
	String METHOD_NAME;
	String SOAP_ACTION;
	public logica(){
		NAMESPACE = "http://webservice/";
		URL = "http://10.37.49.175:8080/ServidorCentral/WebServiceCentral";
		//URL = "http://192.168.1.41:8080/ServidorCentral/WebServiceCentral?wsdl";
		METHOD_NAME = "suma";
		SOAP_ACTION = "http://webservice/suma";
		
	}
	public String sum(String i){
		String resp="";
		String envio="";
		String recepcion="";
		try{
			
			
		

		//int opt1 = i;
		
		SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

		PropertyInfo propInfo1 = new PropertyInfo();
		propInfo1.setName("arg0");
		propInfo1.setValue(i);
		propInfo1.setType(PropertyInfo.STRING_CLASS);
		request.addProperty(propInfo1);
		
		//request.addProperty(METHOD_NAME, opt1);
		
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
		envelope.setOutputSoapObject(request);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
		androidHttpTransport.call(SOAP_ACTION, envelope);
		envio=androidHttpTransport.requestDump;
		recepcion=androidHttpTransport.responseDump;
		
		

		SoapPrimitive   resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();

		resp = resultsRequestSOAP.toString();
		//resp = Integer.parseInt(resps);
		
		}catch (XmlPullParserException e) {
            // TODO Auto-generated catch block

            e.printStackTrace();
    
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return resp;
	}

}
